//
//  XiTongMainViewController.m
//  DirectProDuct
//
//  Created by hl on 16/1/20.
//  Copyright (c) 2016年 ping. All rights reserved.
//

#import "XiTongMainViewController.h"
#import "HomeMainView.h"
#import "ZhanNeiXinJianViewController.h"
#import "XTGongGaoViewController.h"
#import "AccountViewController.h"
@interface XiTongMainViewController ()<HomeMainViewDelegate,UITextFieldDelegate>{
    HomeMainView *mainView;
}

@end

@implementation XiTongMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self drawNavWithTitle:@"后台通用系统"];
    [self drawView];
    // Do any additional setup after loading the view.
}
-(void)drawView{
    mainView = [[HomeMainView alloc] initWithFrame:CGRectMake(0, 78, KScreenWidth, 218 * _kscH)];
    mainView.delegate = self;
    mainView.searchField.delegate = self;
    [self.view addSubview:mainView];
    
    NSArray *titleArr = @[@"系统购买",@"帮助中心",@"商品问题",@"关于我们",@"意见反馈",@"退出系统"];
    
    for (int i = 0; i<6; i++) {
        UIButton *btn = [self createdButtonViewWithTitle:[titleArr objectAtIndex:i] withIndex:i];
        [btn addTarget:self action:@selector(helpClicked:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:btn];
    }
}
-(UIButton *)createdButtonViewWithTitle:(NSString *)titleStr withIndex:(int)index{
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(index * (KScreenWidth/6), KScreenHeight - 30 * _kscH, KScreenWidth/6, 30 * _kscH)];
    btn.tag = index;
    btn.backgroundColor = [UIColor redColor];
    [btn setTitle:titleStr forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont fontWithName:TextJiaCu size:12.0f];
    return btn;
}
#pragma mark 功能按钮代理方法
-(void)buttonCilicked:(UIButton *)btn{

//    switch (btn.tag) {
//        case 0:  break;//系统首页
//        case 1:
//            
//            
//            break;//站内信件
//        case 2:  break;//系统公告
//        case 3:  break;//资金明细
//        case 4:  break;//会员管理
//        case 5:  break;//业务管理
//        case 6:  break;//财务管理
//        case 7:  break;//账户设置
//        case 8:  break;//搜索
//            
//        default:
//            break;
//    }
    if (btn.tag == 0) {
        
    }else if (btn.tag == 1){
        ZhanNeiXinJianViewController *xinJian = [[ZhanNeiXinJianViewController alloc] init];
        [self.navigationController pushViewController:xinJian animated:YES];
    }else if (btn.tag== 2){
        XTGongGaoViewController *gongGao = [[XTGongGaoViewController alloc] init];
        [self.navigationController pushViewController:gongGao animated:YES];
    }else if (btn.tag == 3){
        
    }else if (btn.tag == 4){
        
    }else if (btn.tag == 5){
        
    }else if (btn.tag == 6){
        
    }else if (btn.tag == 7){
        AccountViewController *account = [[AccountViewController alloc] init];
        [self.navigationController pushViewController:account animated:YES];
    }else if (btn.tag == 8){
        
    }
    
}
#pragma mark 底部button方法
-(void)helpClicked:(UIButton *)btn{

    switch (btn.tag) {
        case 0:  break;//系统购买
        case 1:  break;//帮助中心
        case 2:  break;//商品问题
        case 3:  break;//关于我们
        case 4:  break;//意见反馈
        case 5:  break;//退出系统
    
        default:
            break;
    }

}
#pragma mark text代理
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    //进行搜索
    [textField resignFirstResponder];
    return YES;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
